package com.dhms.uikit

import android.graphics.Rect
import android.view.View
import android.widget.HorizontalScrollView
import androidx.recyclerview.widget.RecyclerView

class SpacesItemDecoration(private val horizontalSpace:Float,
                           private val verticalSpace: Float)
    : RecyclerView.ItemDecoration() {
    public final override fun getItemOffsets(
        outRect: Rect,
        view: View,
        parent: RecyclerView,
        state: RecyclerView.State
    ): Unit
    {
        outRect.left = horizontalSpace.toInt()
        outRect.right = horizontalSpace.toInt()
        outRect.bottom = verticalSpace.toInt()

        // Add top margin only for the first item to avoid double space between items
        if (parent.getChildAdapterPosition(view) == 0) {
            outRect.top = verticalSpace.toInt()
        }
    }
}